package com.kfm.boot.service;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

@SpringBootTest
public class MailService {

    @Autowired
    private JavaMailSender javaMailSender;

    @Value("${spring.mail.username}")
    private String from;

    @Test
    public void send(){
        SimpleMailMessage mailMessage = new SimpleMailMessage();

        mailMessage.setFrom(from);

        mailMessage.setTo("1085473391@qq.com");

        mailMessage.setSubject("SpringBoot Mail Test");

        mailMessage.setText("This is a test mail");

        javaMailSender.send(mailMessage);
    }
}
